package com.sh.data.engine.web.webapi.controller.authority;

import com.sh.data.engine.application.service.authority.MenuApplicationService;
import com.sh.data.engine.domain.authority.model.domain.MenuDomain;
import com.sh.data.engine.web.webapi.controller.base.response.RestResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author tinglan.ys @Title: @Package: @Description:
 * @date 2022/1/5 下午3:21
 */
@RequestMapping("/menu")
@RestController
@Tag(name = "菜单管理", description = "菜单管理(菜单直接操作数据库进行维护，不暴露增删改接口)")
public class MenuController {

    @Autowired
    private MenuApplicationService menuApplicationService;

    /**
     * @description : 菜单列表
     * @author : tinglan.ys
     * @date : 2022/1/5
     */
    @GetMapping("/list")
    @Operation(summary = "角色配置那里的菜单列表")
    public RestResponseEntity<List<MenuDomain>> menuList() {
        var result = menuApplicationService.listMenus();
        return RestResponseEntity.success(result);
    }

    @GetMapping("/listId")
    @Operation(summary = "获取全量菜单Id,证书里要用")
    public RestResponseEntity<String> listId() {
        var result = menuApplicationService.listId();
        return RestResponseEntity.success(result);
    }

    /**
     * @description : 菜单详情
     * @author : tinglan.ys
     * @date : 2022/1/13
     */
    @GetMapping("/getMenusById")
    @Operation(summary = "菜单详情")
    public RestResponseEntity<MenuDomain> getMenusById(@RequestParam Long id) {
        var result = menuApplicationService.getMenusById(id);
        return RestResponseEntity.success(result);
    }
}
